package BitManipulation;

public class _693_BinaryNumberwithAlternatingBits {
    public boolean hasAlternatingBits(int n) {
        int firstBit = n & 1;
        n = n >>> 1;
        while (n != 0) {
            if (((n & 1) ^ firstBit) == 1) {
                firstBit = n & 1;
                n = n >>> 1;
            } else {
                return false;
            }
        }
        return true;
    }
}
